﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VideoNetApplication.Common.Dao
{
  public  class NewsDao
    {
      public  V_News GetNewsById(int id)
      {
          using (EVDBEntities edm=new EVDBEntities())
          {
              return edm.V_News.FirstOrDefault(s => s.ID == id);
          }

      }

      public List<V_News> GetNewsList(int schoolId, int starIndex, int maxRow, out int recordCount)
      {
          using (EVDBEntities edm=new EVDBEntities())
          {
              recordCount = edm.V_News.Count(s => s.SchoolId == schoolId && s.IsPublished == 1);
              return 
                  edm.V_News.Where(s => s.SchoolId == schoolId&&s.IsPublished==1).OrderByDescending(s => s.ID).Skip(starIndex - 1).Take(maxRow).
                      ToList();
          }

      }

    }
}
